﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="BuXiaChu.OrderDishes.Web.CallCenter.Index" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link media="screen, projection" rel="stylesheet" type="text/css" href="/css/Blueprint/screen.css" />
    <link media="screen, projection" rel="stylesheet" type="text/css" href="/css/main.css" />

    <script type="text/javascript" src="js/Extend.js"></script>

    <script type="text/javascript" src="js/Common.js"></script>

    <script type="text/javascript" src="js/jquery-vsdoc.js"></script>

</head>
<body>
    <div class="container">
        <div class="span-2 boxc">
            <p>
                <input type="button" id="btn_SendNotice" onclick="window.open('Notice.aspx')" value="发布公告" /></p>
            <p>
                <a href="/Order/OrderList.aspx" target="_blank">订单查询</a></p>
            <p>
                <a href="/LoginOut.aspx">退出系统</a></p>
            <p>
                <%= BuXiaChu.OrderDishes.BLL.CookieManager.LoginSysUserInfo.Intance.RealName %></p>
        </div>
        <div class="span-21 last">
            <div class="span-21 last boxc">
                <div class="span-1">
                    <h1 style="padding: 50px 0px 10px 0px;">
                        用户信息</h1>
                </div>
                <div class="span-12">
                    <div class="editor-content">
                        <input type="hidden" id="txt_UserId" value="0" />
                        <input type="hidden" id="txt_AddressId" value="0" />
                        <div class="editor-label">
                            <label>
                                来电号码</label>
                        </div>
                        <div class="editor-field">
                            <input type="text" class="title" id="txt_CallerID" style="color: Red; font-weight: bold;" />
                        </div>
                        <div class="editor-label">
                            <label>
                                联系人</label>
                        </div>
                        <div class="editor-field">
                            <input type="text" class="title" id="txt_MrName" style="width: 100px;" />
                            先生
                            <input type="text" class="title" id="txt_MsName" style="width: 100px;" />
                            女士
                        </div>
                        <div class="editor-label">
                            <label>
                                关联号码</label>
                        </div>
                        <div class="editor-field">
                            <input type="text" class="title" id="txt_Tel" />
                        </div>
                        <div class="editor-label">
                            <label>
                                用户地址</label>
                        </div>
                        <div class="editor-field">
                            <input type="text" class="title" id="txt_Address" />
                        </div>
                        <div class="editor-label">
                            <label>
                                发票抬头</label>
                        </div>
                        <div class="editor-field">
                            <input type="text" class="title" id="text_InvoiceTitle" />
                        </div>
                    </div>
                </div>
                <div class="span-8 last">
                    <div class="boxc">
                        <h3>
                            关联信息</h3>
                        <div id="div_AddressList" class="list">
                        </div>
                    </div>
                </div>
            </div>
            <div class="span-21 last boxc">
                <div class="span-16">
                    <div>
                        <input type="button" id="btn_CreateNewOrder" value="新建订单" /></div>
                    <hr />
                    <div id="div_Order">
                        <table class="list">
                            <tr>
                                <td>
                                    用餐时间
                                </td>
                                <td class="value">
                                    <input type="text" id="txt_DinnerD" class="date" />
                                    <input type="text" id="txt_DinnerH" class="time" /><span>:</span>
                                    <input type="text" id="txt_DinnerM" class="time" />
                                </td>
                                <td>
                                    订餐时间
                                </td>
                                <td class="value">
                                    <span id="sp_OrderTime"></span>
                                </td>
                                <td>
                                    接线员
                                </td>
                                <td class="value">
                                    黎明
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    送餐区域
                                </td>
                                <td class="value">
                                    <select id="sel_Area" runat="server">
                                    </select>
                                </td>
                                <td colspan="4" class="value">
                                    <input type="button" disabled="disabled" id="btn_OrderDishes" value="点菜" />
                                </td>
                            </tr>
                        </table>
                        <div>
                            <h3 class="bottom">
                                订单详情</h3>
                        </div>
                        <table class="list" id="tbl_SelectedDishes">
                            <tr>
                                <td style="display: none">
                                </td>
                                <td style="display: none">
                                </td>
                                <td>
                                    餐厅名称
                                </td>
                                <td>
                                    菜品名称
                                </td>
                                <td>
                                    菜品类别
                                </td>
                                <td>
                                    单价
                                </td>
                                <td>
                                    单位
                                </td>
                                <td>
                                    数量
                                </td>
                                <td>
                                    备注
                                </td>
                                <td>
                                    操作
                                </td>
                            </tr>
                        </table>
                        <table style="width: 400px">
                            <tr>
                                <td>
                                    总送餐金额：<span id="sp_Amount"></span>元
                                </td>
                                <td>
                                    餐厅折扣金额：<span id="sp_DiscountAmount"></span>元
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    送餐费：<span id="sp_Freight">0</span>元
                                </td>
                                <td>
                                餐盒数量<span id="sp_BoxNum">0</span>&nbsp
                                餐盒总金额<span id="sb_BoxAmount">0</span>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    总应收金额：<em id="sp_Total"></em>元
                                </td>
                                <td>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td>
                                    <input type="button" id="btn_ConfirmOrder" value="确定" />
                                    <input type="button" id="btn_CancleOrder" value="取消" />
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="span-4 last boxc">
                    <div id="div_NoticeList" data-lastid="0" style="height: 400px; overflow: auto">
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>

<script type="text/javascript" src="js/Order/Order.js"></script>

<script type="text/javascript" src="js/PagePromptBox.js"></script>

<script type="text/javascript">
    (function () {
        function disabledOrderElem(b) {
            jDoc.getElementsBy("div_Order", "input", function (e) {
                if (!b && e.id == "btn_OrderDishes") {
                    return;
                }
                e.disabled = b;
            })
            jDoc("sel_Area").disabled = b;
        }
        disabledOrderElem(true);
        orderManager.isOrderDishesPage = false;
        orderManager.getDate();

        $(jDoc("btn_CreateNewOrder")).click(function () {
            disabledOrderElem(false);
            orderManager.getDate();
        });

        $(jDoc("sel_Area")).change(function () {
            var value = this.options[this.selectedIndex].value;
            if (value > 0) {
                jDoc("btn_OrderDishes").disabled = false;
            } else {
                jDoc("btn_OrderDishes").disabled = true;
            }
        });
        function collectUserInfo(postData) {
            postData.userId = jDoc("txt_UserId").value;
            postData.addressId = jDoc("txt_AddressId").value;
            var callerId = jDoc("txt_CallerID").value.trim();
            var tel = jDoc("txt_Tel").value.trim();
            if (callerId == "" && tel == "") {
                alert("请输入电话");
                return false;
            }
            if (callerId.length == 11) {
                postData.mobile = callerId;
                postData.tel = tel;
            } else {
                postData.mobile = tel;
                postData.tel = callerId;
            }
            var mrName = jDoc("txt_MrName").value.trim();
            var msName = jDoc("txt_MsName").value.trim();
            if (mrName == "" && msName == "") {
                jDoc("txt_MrName").focus();
                alert("请输入联系人");
                return false;
            }
            if (mrName != "") {
                postData.gender = 0;
                postData.name = mrName;
            } else {
                postData.gender = 1;
                postData.name = msName;
            }
            var address = jDoc("txt_Address").value.trim();
            if (address == "") {
                jDoc("txt_Address").focus();
                alert("请输入用户地址");
                return false;
            }
            postData.address = address;
            var invoiceTitle = jDoc("text_InvoiceTitle").value.trim();
            postData.invoicTitle = invoiceTitle;
        }
        function collectBaseInfo() {
            var postData = { t: 2, cityId: 10 }, id = 0, num = 0, cell = {};
            if (collectUserInfo(postData) == false) {
                return null;
            }
            var area = jDoc("sel_Area");
            postData.areaId = area.options[area.selectedIndex].value;
            postData.freight = jDoc("sp_Freight").innerHTML;
            postData.lastTime = String.format("{0} {1}:{2}", jDoc("txt_DinnerD").value, jDoc("txt_DinnerH").value, jDoc("txt_DinnerM").value);
            return postData;
        }
        $(jDoc("btn_ConfirmOrder")).click(function () {
            if (orderManager.cacheData.length < 1) {
                alert("请选择菜品");
                return;
            }
            var postData = collectBaseInfo();
            if (postData == null) return false;
            orderManager.setRmarksToCacheData();
            var cacheDataList = orderManager.cacheData, id = 0, num = 1;
            for (var i = 0, len = cacheDataList.length; i < len; i++) {
                id = cacheDataList[i].id;
                num = cacheDataList[i].number;//maybe loop attr
                postData["restaurantId_" + id] = cacheDataList[i].restaurantId; //
                postData["restaurantName_" + id] = cacheDataList[i].restaurantName; //
                postData["dishesId_" + id] = num;
                postData["dishesName_" + id] = cacheDataList[i].name;
                postData["remarks_" + id] = cacheDataList[i].remarks;
                postData["price_" + id] = cacheDataList[i].price;
                postData["unit_" + id] = cacheDataList[i].unit;
                postData["discount_" + id] = cacheDataList[i].discount;
                postData["invoiceDiscount_" + id] = cacheDataList[i].invoiceDiscount;
                postData["boxNum_" + id] = cacheDataList[i].boxNum;
                postData["boxPrice_" + id] = cacheDataList[i].boxPrice;
                //discount
            }
            //alert(Object.convertJSONToString(postData));
            //return;
            $.post(orderManager.url.order, postData,
                function (data) {
                    if (data.success) {
                        orderManager.clearClientInfo(true);
                        alert("下单成功");
                    } else {
                        alert("下单失败");
                    }
                }, "json");
        });

        $(jDoc("btn_CancleOrder")).click(function () {
            orderManager.delAllCacheData();
            jDoc("sel_Area").disabled = false;
        });
        $(jDoc("btn_OrderDishes")).click(function () {
            var area = jDoc("sel_Area");
            var areaId = area.options[area.selectedIndex].value;
            orderManager.dishesListPage = window.open("/Order/DishesList.aspx");
            webPB.showDialog("<span><h2>必须关闭点菜页面此影印才能消失</h2></span>");
            jDoc("sel_Area").disabled = true;
        });
    })();  
</script>

<script type="text/javascript" src="js/Index/Index.js">
</script>

<script type="text/javascript">
    //setInterval(getNoticeList, 10000);
    //getNoticeList();
    
</script>

<script type="text/javascript">
    function window.onhelp() {
        return false
    }
    
</script>

